package com.wangtianxiang.sxp.common.http;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;

@SuppressWarnings("serial")
public class FeedBackBody<T> implements Serializable {
	/**返回码*/
	@JsonIgnore
	private BizCode bizCode;
	/**返回系统定义信息*/
	private String msg;
	/**返回信息*/
	private String detail;
	/**返回信息*/
	private T result;


	public FeedBackBody(){
		
	}
	public FeedBackBody(BizCode bizCode){
		this.bizCode= bizCode;
		this.msg=bizCode.getMsg();
		this.detail = bizCode.getDetail();
		
	}	
	public FeedBackBody(T t){
		this.result= t;
	}
	
	@JSONField(name="code")
	public String getCode() {
		return this.bizCode.value();
	}
	
	@JSONField(name="code")
	public FeedBackBody<T> setCode(String code) {
		this.bizCode = BizCode.valueOfCode(code);
		return this;
	}
	
	@JSONField(serialize = false)
	public BizCode getBizCode() {
		return this.bizCode;
	}
	
	@JSONField(deserialize = false)
	public FeedBackBody<T> setBizCode(BizCode bizCode) {
		this.bizCode = bizCode;
		return this;
	}
	
	/**
	 * 获取详细描述信息
	 * @return
	 */
	public String getDetail() {
		return detail;
	}
	
	/**
	 * 设置详细描述信息
	 * @param detail
	 * @return
	 */
	public FeedBackBody<T> setDetail(String detail) {
		this.detail = detail;
		return this;
	}
	
	/**
	 * 获取系统定义信息
	 * @return
	 */
	public String getMsg() {
		return msg;
	}
	/**
	 * 设置系统定义信息
	 * @param msg
	 * @return
	 */
	public FeedBackBody<T> setMsg(String msg) {
		this.msg = msg;
		return this;
	}
	public T getResult() {
		return result;
	}
	public FeedBackBody<T> setResult(T t) {
		this.result = t;
		return this;
	}

	public String toJSONString(){
		return JSONObject.toJSONString(this);
	}
}
